for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
// spec/index.spec.js
"use strict";
// :: DEPENDENCIES
// load native dependencies
const path = require("path");
// load local dependencies
const root = path.dirname(__dirname);
const ejsception = require(path.join(root, "index.js"));
const Throwable = require(path.join(root, "Throwable.js"));
const Exception = require(path.join(root, "Exception.js"));
// All accessible 'classes'
const classes = [
"Throwable",
"Exception"
];
// wrap them in a plain object
const local = {
Throwable,
Exception
};
// :: TESTING
// test the module
describe("ejsception | @egalabs/exception", () => {
// :: VARIABLES
let key;
const test = (() => ejsception[key] = 0);
const suite = (() => {
expect(ejsception[key]).toEqual(local[key]);
expect(ejsception[key].prototype).toEqual(local[key].prototype);
});
it("should me immutable", () => {
for (let i = 0; i < classes.length; i += 1) {
key = classes[i];
expect(test).toThrowErrorOfType("TypeError");
}
// test all 'classes'
it("should have a " + key + " 'class'", suite);